package mine.code.practice;

import org.junit.Test;

import java.util.Arrays;

/**
 * @author caijinnan
 */
public class 多集合之间全排列 {

    @Test
    public void run() {
        int[][] a = {{1, 2}, {3, 4}, {5, 6}};
        int[] result = new int[a.length];
        getPermutation(a, a.length, 0, result);
    }


    public void getPermutation(int[][] array, int length, int index, int[] result) {
        if (index == length) {
            System.out.println(Arrays.toString(result));
            return;
        }
        for (int i = 0; i < array[index].length; i++) {
            result[index] = array[index][i];
            getPermutation(array, length, index + 1, result);
        }
    }
}
